import random

ips = "172.25.254."
lst1 = []
dict1 = {}
with open("ip.txt", "w+") as f:
    for i in range(2000):
        ran_num = random.randint(0, 255)
        str2 = f"{ips}{ran_num}\n"
        lst1.append(str2)
        f.write(str2)
# 用集合统计ip出现的次数
my_set = set(lst1)
for j in my_set:
    dict1.update({j: lst1.count(j)})

rank = sorted(dict1.items(), key=lambda x: x[1])
lst2 = rank[-1:-11:-1]
for m, n in lst2:
    print(m, "出现了", n, "次")



